package com.newlink.building.login.mvp.presenter

import com.newlink.building.login.mvp.contract.Module_Login_InputVerifySMSCodeContract
import com.newlink.building.login.mvp.model.Module_Login_InputVerifySMSCodeModel
import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.http.exception.Base_ErrorStatus
import com.newlink.building.common_base.utils.logDebug

/**
 * @Author: Jake
 * @Date: 2023-04-06
 * @Description:
 */
class Module_Login_InputVerifySMSCodePresenter :
    BasePresenter<Module_Login_InputVerifySMSCodeContract.Model, Module_Login_InputVerifySMSCodeContract.View>(),
    Module_Login_InputVerifySMSCodeContract.Presenter {

    override fun createModel(): Module_Login_InputVerifySMSCodeContract.Model = Module_Login_InputVerifySMSCodeModel()

    override fun sendVerifySMSCode(area: String, mobileNumber: String, code: String) {
        mModel?.sendVerifySMSCode(area, mobileNumber, code)?.ss(mModel, mView) {
            logDebug<Module_Login_InputVerifySMSCodePresenter>("sendVerifySMSCode response ->  ${it?.data}")
            if (it?.code == Base_ErrorStatus.SUCCESS) {
                if (it.data == true) {
                    mView?.sendVCSuccess()
                } else {
                    mView?.sendVCFailed(it?.msg)
                }
            } else {
                mView?.sendVCFailed(it?.msg)
            }
        }
    }
}